<template>
  <el-row class="org-manage">
<el-col :span="24">
<p>组织管理:&nbsp;&nbsp;北京慧筑致远</p>
</el-col>
<el-col :span="24" class="table-style">
 <el-table ref="obsTable"                   
                    :highlight-current-row="true"
                    :header-cell-style="{background:'#f5f5f5'}"
                    :data="tableData"
                    border
                    height="500px"
                    class="obs-style">
            <el-table-column type="index"
                             label="序号"
                             width="100px"
                             align="center"
                             show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="org_name"
                             label="组织名称"
                             align="center"
                             show-overflow-tooltip>
            </el-table-column>
            <el-table-column label="操作"
                             align="center">
              <template slot-scope="scope">
                <el-button width="80px"
                           size="mini" 
                           @click="onEdit(scope.row)"                         
                           type="text">
                编辑
                </el-button>                
                 <el-button width="80px"
                           size="mini" 
                           @click="ViewQRCode(scope.row)"                         
                           type="text">
                查看二维码
                </el-button>                 
              </template>
            </el-table-column>
          </el-table>
</el-col>
<el-dialog
  title="编辑组织"
  :visible.sync="editOrgDialog"
  width="30%"
  :before-close="handleClose">
 <EditOrgDialog :todos="todos" :catchSave="catchSave" :catchBack="catchBack" :objData="objData"></EditOrgDialog>
</el-dialog>
<el-dialog
  title="查看二维码"
  :visible.sync="viewQRCodeDialog"
  width="30%">
<QRCode :todos="todos" :catchClose="catchClose"></QRCode>
</el-dialog>
  </el-row>
</template>

<script>
import QRCode from './components/QRCode'
import EditOrgDialog from './components/EditOrgDialog'
export default {
  components:{
  EditOrgDialog,
  QRCode,
  },
data(){
  return{
    viewQRCodeDialog:false,
    objData:{},
    todos:0,
    todosQR:'',
  editOrgDialog:false,
  tableData:[{id:1,org_name:'北京慧筑致远'}]
  }
},
  computed: {
    getOrg () {
      return this.$store.state.getBuildOrg
    },
    getJoinOrg(){
       return this.$store.state.getJoinOrg
    },
    changeOrgOrStation(){
      return this.$store.state.changeOrgOrStation
    }
  },
  watch: {
    getOrg (newval, oldval) {//建立组织
    console.log('建立组织-监听-addBuildOrg=',newval);
    },
    getJoinOrg(n,o){//加入组织
       console.log('加入组织-监听-joinOrg=',n);
    },
    changeOrgOrStation(n,o){//切换组织或岗位
      console.log('切换组织或岗位-监听-joinOrg=',n);
    }
  },
methods:{
  //关闭
  catchClose(){
this.todosQR='';
this.viewQRCodeDialog=false;
  },
  //子组件保存时触发该事件
  catchSave(){
  this.catchBack();
  },
    //子组件取消时触发该事件
  catchBack(){
    this.objData={}
  this.todos=0;
  this.editOrgDialog=false;
  },
handleClose(done){
done()
},
//查看二维码
ViewQRCode(row){
  this.todos="http://dev-hibuilding-new.oss-cn-hangzhou.aliyuncs.com/industry/industry/pic/日报项目填写.jpg"
  this.viewQRCodeDialog=true;
  console.log('查看二维码=',row)
},
//编辑
onEdit(row){
  this.objData=row;
  this.todos=1;
this.editOrgDialog=true;
}
},
mounted(){

},
created(){
console.log('csy=state.getBuildOrg=',this.$store.state.getBuildOrg)
}
}
</script>

<style lang="scss" scoped>
.org-manage{
  padding:20px;
}
.table-style{
  margin-top:20px;
}
</style>